package cn.springcloud.fix.demo.collection;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;

/**
 * http://ifeve.com/java-blocking-queue/
 */
public class BlockingQueueDemo {

    /**
     * add方法如果超出容量会抛异常
     * removeFirst方法也会抛异常
     */
    public static void main(String[] args) {

        LinkedBlockingDeque<Integer> queue = new LinkedBlockingDeque<>(3);
        queue.add(1);
        queue.add(2);
        queue.removeFirst();
        queue.removeFirst();
        queue.add(3);
        queue.add(4);
        queue.add(5);

        System.out.println(queue.toString());
    }
}
